#ifndef __RENDER_OBJECT_H__
#define __RENDER_OBJECT_H__
#include "cocos2d.h"
#include "../config/AniConfig.h"
namespace fishingjoy
{
	namespace scene
	{
		class CRenderObject:public cocos2d::CCSprite
		{
			const config::CAniObjectData* mAniObjectData;
		public:
			CRenderObject(int tid)
			{
				init();
				mAniObjectData = config::CAniConfig::getData(tid);
				if(mAniObjectData){
					const char* de = mAniObjectData->getDefaultAni();
					setAni(de);
				}
			}
			void setAni(const char* aniName)
			{
				if(mAniObjectData){
					const config::SAniData* pData = mAniObjectData->getAni(aniName);
					if(pData){
						cocos2d::CCAnimation* pAnimation = cocos2d::CCAnimation::createWithSpriteFrames(pData->Frames,pData->Delay);
						this->cleanup();
						this->runAction(cocos2d::CCRepeatForever::create(cocos2d::CCAnimate::create(pAnimation)));
					}
				}
			}
		public:
			void update(float dt)
			{
				//printf("update render object\n");
			}
		};
	}
}
#endif